import java.awt.EventQueue;
import java.awt.List;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.border.LineBorder;
import java.awt.Color;
import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;

public class MainFrame extends JFrame {

	private List linkLists = new List();

	private JPanel contentPane;
	private JTextArea textShow;
	private JPanel panelOption;
	private JComboBox<LinkList> comboBox;
	private JButton btnAdd;

	private JPanel panelNew;
	private JTextArea textArea_New;
	private JRadioButton rdbtnPolynomial;
	private JRadioButton rdbtnLinklist;

	private JPanel panelGet;
	private JTextField textIndex_Get;
	private JTextField textValue_Get;
	private JLabel labelResult_Insert;

	private JPanel panelInsert;
	private JTextField textIndex_Insert;
	private JTextField textValue_Insert;

	private JPanel panelDelect;
	private JTextField textIndex_Delect;
	private JLabel labelResult_Delect;

	private JPanel panelFind;
	private JTextField textValue_Find;
	private JLabel labelResult_find;

	private JPanel panelShow;
	private JLabel labelMessage_Show;

	private JPanel panelAdd;
	private JComboBox<LinkList> comboBox_P;
	private JTextArea textAdd;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainFrame frame = new MainFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MainFrame() {
		setTitle("Linear list");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 551, 435);
		contentPane = new JPanel();
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JButton btnNew = new JButton("New");
		btnNew.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				switchPanel("New");
			}
		});
		btnNew.setBounds(391, 14, 113, 27);
		contentPane.add(btnNew);

		JButton btnClear = new JButton("Clear");
		btnClear.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnClear_P_call();
			}
		});
		btnClear.setBounds(391, 55, 113, 27);
		contentPane.add(btnClear);

		JButton btnLength = new JButton("Length");
		btnLength.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnLength_P_call();
			}
		});
		btnLength.setBounds(391, 96, 113, 27);
		contentPane.add(btnLength);

		JButton btnIsEmpty = new JButton("isEmpty");
		btnIsEmpty.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnIsEmpty_P_call();
			}
		});
		btnIsEmpty.setBounds(391, 137, 113, 27);
		contentPane.add(btnIsEmpty);

		JButton btnGetValue = new JButton("getValue");
		btnGetValue.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (comboBox.getItemCount() == 0) {
					return;
				}
				switchPanel("Get");
			}
		});
		btnGetValue.setBounds(391, 178, 113, 27);
		contentPane.add(btnGetValue);

		JButton btnInsert = new JButton("Insert");
		btnInsert.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (comboBox.getItemCount() == 0) {
					return;
				}
				switchPanel("Insert");
			}
		});
		btnInsert.setBounds(391, 219, 113, 27);
		contentPane.add(btnInsert);

		JButton btnDelect = new JButton("Delect");
		btnDelect.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (comboBox.getItemCount() == 0) {
					return;
				}
				switchPanel("Delect");
			}
		});
		btnDelect.setBounds(391, 260, 113, 27);
		contentPane.add(btnDelect);

		textShow = new JTextArea();
		textShow.setEditable(false);
		textShow.setLineWrap(true);
		textShow.setBounds(14, 46, 363, 140);
		contentPane.add(textShow);
		textShow.setColumns(10);

		JLabel lblNewLabel = new JLabel("Link list:");
		lblNewLabel.setBounds(14, 14, 87, 18);
		contentPane.add(lblNewLabel);

		JButton btnFind = new JButton("Find");
		btnFind.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (comboBox.getItemCount() == 0) {
					return;
				}
				switchPanel("Find");
			}
		});
		btnFind.setBounds(391, 301, 113, 27);
		contentPane.add(btnFind);

		panelOption = new JPanel();
		panelOption.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelOption.setBounds(14, 200, 363, 172);
		contentPane.add(panelOption);
		panelOption.setLayout(null);

		comboBox = new JComboBox();
		comboBox.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent arg0) {
				chageLinkList();
			}
		});
		comboBox.setBounds(96, 11, 281, 24);
		contentPane.add(comboBox);

		btnAdd = new JButton("Add");
		btnAdd.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				btnAdd_call();
			}
		});
		btnAdd.setBounds(391, 342, 113, 27);
		contentPane.add(btnAdd);

		// -------------------------------------
		panelNew = new JPanel();
		panelNew.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelNew.setBounds(0, 0, 363, 172);
		panelNew.setLayout(null);

		textArea_New = new JTextArea();
		textArea_New.setBounds(15, 40, 334, 80);
		panelNew.add(textArea_New);

		JLabel lblValues_New = new JLabel("Values(split by comma):");
		lblValues_New.setBounds(15, 11, 257, 18);
		panelNew.add(lblValues_New);

		JButton btnNew_P = new JButton("New");
		btnNew_P.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnNew_P_call();
			}
		});
		btnNew_P.setBounds(243, 136, 109, 27);
		panelNew.add(btnNew_P);

		rdbtnLinklist = new JRadioButton("Link List");
		rdbtnLinklist.setSelected(true);
		rdbtnLinklist.setBounds(11, 136, 101, 27);
		panelNew.add(rdbtnLinklist);

		rdbtnPolynomial = new JRadioButton("Polynomial");
		rdbtnPolynomial.setBounds(123, 136, 109, 27);
		panelNew.add(rdbtnPolynomial);

		ButtonGroup buttonGroup = new ButtonGroup();
		buttonGroup.add(rdbtnLinklist);
		buttonGroup.add(rdbtnPolynomial);

		// --------------------------------------
		panelGet = new JPanel();
		panelGet.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelGet.setBounds(0, 0, 363, 172);
		panelGet.setLayout(null);

		JLabel lblIndex_Get = new JLabel("Index:");
		lblIndex_Get.setBounds(14, 45, 56, 18);
		panelGet.add(lblIndex_Get);

		textIndex_Get = new JTextField();
		textIndex_Get.setColumns(10);
		textIndex_Get.setBounds(70, 42, 163, 24);
		panelGet.add(textIndex_Get);

		JButton btnGet_P = new JButton("getValue");
		btnGet_P.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnGet_P_call();
			}
		});
		btnGet_P.setBounds(247, 41, 102, 27);
		panelGet.add(btnGet_P);

		JLabel lblValue_Get = new JLabel("Value:");
		lblValue_Get.setBounds(14, 108, 56, 18);
		panelGet.add(lblValue_Get);

		textValue_Get = new JTextField();
		textValue_Get.setColumns(10);
		textValue_Get.setBounds(70, 105, 279, 24);
		panelGet.add(textValue_Get);

		// --------------------------------------------------
		panelInsert = new JPanel();
		panelInsert.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelInsert.setLayout(null);
		panelInsert.setBounds(0, 0, 363, 172);

		JLabel labelIndex_Insert = new JLabel("Index:");
		labelIndex_Insert.setBounds(14, 29, 56, 18);
		panelInsert.add(labelIndex_Insert);

		textIndex_Insert = new JTextField();
		textIndex_Insert.setColumns(10);
		textIndex_Insert.setBounds(70, 26, 163, 24);
		panelInsert.add(textIndex_Insert);

		JButton btnInsert_P = new JButton("insert");
		btnInsert_P.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnInsert_P_call();
			}
		});
		btnInsert_P.setBounds(247, 50, 102, 27);
		panelInsert.add(btnInsert_P);

		JLabel label_1 = new JLabel("Value:");
		label_1.setBounds(14, 76, 56, 18);
		panelInsert.add(label_1);

		textValue_Insert = new JTextField();
		textValue_Insert.setColumns(10);
		textValue_Insert.setBounds(70, 73, 163, 24);
		panelInsert.add(textValue_Insert);

		labelResult_Insert = new JLabel();
		labelResult_Insert.setHorizontalAlignment(SwingConstants.CENTER);
		labelResult_Insert.setBounds(14, 123, 335, 18);
		panelInsert.add(labelResult_Insert);

		// --------------------------------------------
		panelDelect = new JPanel();
		panelDelect.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelDelect.setLayout(null);
		panelDelect.setBounds(0, 0, 363, 172);

		JLabel labelIndex_Delect = new JLabel("Index:");
		labelIndex_Delect.setBounds(14, 45, 56, 18);
		panelDelect.add(labelIndex_Delect);

		textIndex_Delect = new JTextField();
		textIndex_Delect.setColumns(10);
		textIndex_Delect.setBounds(70, 42, 163, 24);
		panelDelect.add(textIndex_Delect);

		JButton btnDelect_P = new JButton("Delect");
		btnDelect_P.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnDelect_P_call();
			}
		});
		btnDelect_P.setBounds(247, 41, 102, 27);
		panelDelect.add(btnDelect_P);

		labelResult_Delect = new JLabel();
		labelResult_Delect.setHorizontalAlignment(SwingConstants.CENTER);
		labelResult_Delect.setBounds(14, 108, 335, 18);
		panelDelect.add(labelResult_Delect);

		// --------------------------------------------------
		panelFind = new JPanel();
		panelFind.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelFind.setLayout(null);
		panelFind.setBounds(0, 0, 363, 172);

		JLabel lblValue_Find = new JLabel("Value:");
		lblValue_Find.setBounds(14, 45, 56, 18);
		panelFind.add(lblValue_Find);

		textValue_Find = new JTextField();
		textValue_Find.setColumns(10);
		textValue_Find.setBounds(70, 42, 163, 24);
		panelFind.add(textValue_Find);

		JButton btnFind_P = new JButton("Find");
		btnFind_P.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnFind_P_call();
			}
		});
		btnFind_P.setBounds(247, 41, 102, 27);
		panelFind.add(btnFind_P);

		labelResult_find = new JLabel();
		labelResult_find.setHorizontalAlignment(SwingConstants.CENTER);
		labelResult_find.setBounds(14, 108, 335, 18);
		panelFind.add(labelResult_find);

		// -----------------------------------
		panelShow = new JPanel();
		panelShow.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelShow.setLayout(null);
		panelShow.setBounds(0, 0, 363, 172);

		labelMessage_Show = new JLabel("Empty Message!");
		labelMessage_Show.setHorizontalAlignment(SwingConstants.CENTER);
		labelMessage_Show.setBounds(14, 77, 335, 18);
		panelShow.add(labelMessage_Show);

		// -------------------------------------

		panelAdd = new JPanel();
		panelAdd.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelAdd.setBounds(0, 0, 363, 172);
		panelAdd.setLayout(null);

		comboBox_P = new JComboBox();
		comboBox_P.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				chagePolynomial();
			}
		});
		comboBox_P.setBounds(124, 13, 225, 24);
		panelAdd.add(comboBox_P);

		JLabel lblPolynomials = new JLabel("Polynomials:");
		lblPolynomials.setBounds(14, 16, 96, 18);
		panelAdd.add(lblPolynomials);

		JButton btnAdd_P = new JButton("Add");
		btnAdd_P.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnAdd_P_call();
			}
		});
		btnAdd_P.setBounds(124, 132, 113, 27);
		panelAdd.add(btnAdd_P);

		textAdd = new JTextArea();
		textAdd.setBounds(14, 50, 335, 69);
		panelAdd.add(textAdd);

		// -------------------------------------
		showMessage("Click New to Start!");
	}

	/**
	 * 切换功能框
	 * 
	 * @param panelName
	 *            需要切换的功能框名
	 */
	private void switchPanel(String panelName) {
		// 去除功能框内原有的功能框
		panelOption.removeAll();
		// 切换对应的功能框
		switch (panelName) {
		case "New":
			textArea_New.setText("");
			panelOption.add(panelNew);
			break;
		case "Get":
			textIndex_Get.setText("");
			textValue_Get.setText("");
			panelOption.add(panelGet);
			break;
		case "Insert":
			textIndex_Insert.setText("");
			textValue_Insert.setText("");
			labelResult_Insert.setText("");
			panelOption.add(panelInsert);
			break;
		case "Delect":
			textIndex_Delect.setText("");
			labelResult_Delect.setText("");
			panelOption.add(panelDelect);
			break;
		case "Find":
			textValue_Find.setText("");
			labelResult_find.setText("");
			panelOption.add(panelFind);
			break;
		case "Show":
			panelOption.add(panelShow);
			break;
		case "Add":
			panelOption.add(panelAdd);
			break;
		}
		// 通知重绘
		panelOption.repaint();
	}

	/**
	 * 显示一个消息或结果
	 * 
	 * @param message
	 *            需要显示的信息
	 */
	private void showMessage(String message) {
		// 设置显示的信息
		labelMessage_Show.setText(message);
		// 切换到消息功能框
		switchPanel("Show");
	}

	/**
	 * 选中的链表改变
	 */
	private void chageLinkList() {
		showMessage("Choose an operation.");
		showLinkList();
	}

	/**
	 * 加法运算中选中的多项式改变
	 */
	private void chagePolynomial() {
		Polynomial polynomial = (Polynomial) comboBox_P.getSelectedItem();
		if (polynomial == null) {
			return;
		}
		textAdd.setText(polynomial.getString());
	}

	/**
	 * 在输出框显示链表
	 */
	private void showLinkList() {
		LinkList linkList = (LinkList) comboBox.getSelectedItem();
		textShow.setText(linkList.getString());
	}

	/**
	 * 新建链表按钮监听调用方法
	 */
	private void btnNew_P_call() {
		// 判断是否有输入
		if (textArea_New.getText().length() < 1) {
			showMessage("input some values!");
			return;
		}
		// 获得输入并解析
		String inputStr = textArea_New.getText();
		String[] input = inputStr.split(",");
		if (rdbtnLinklist.isSelected()) {// 选中创建链表
			LinkList linkList = new LinkList();
			// 循环添加节点
			for (int i = 0; i < input.length; i++) {
				try {
					linkList.addNode(input[i], i);
				} catch (Exception e) {
					showMessage(e.getMessage());
				}
			}
			// 把新建的链表添加到下拉框
			comboBox.addItem(linkList);
			// 选中新建的链表
			comboBox.setSelectedItem(linkList);
			showMessage("Created a LinkList!");
		} else {// 选中创建多项式
			Polynomial polynomial = new Polynomial();
			try {
				// 循环解析输入来生成多项式
				for (int i = 0; i < input.length; i++) {
					String[] termStr = input[i].split(":");
					int expn = Integer.parseInt(termStr[1]);
					double coef = Double.parseDouble(termStr[0]);
					Term term = new Term(coef, expn);
					polynomial.addNode(term, i);
				}
			} catch (ArrayIndexOutOfBoundsException e) {// 无法解析
				showMessage("Error Input!");
				return;
			} catch (Exception e) {
				showMessage(e.getMessage());
				return;
			}
			// 合并多项式的同类项
			polynomial.mergeSimilarTerms();
			// 移除多项式中无意义的项
			polynomial.removeEmptyTerm();
			// 将新建的多项式添加到下拉框
			comboBox.addItem(polynomial);
			// 选中新建的多项式
			comboBox.setSelectedItem(polynomial);
			showMessage("Created a Polynomial!");
		}
		showLinkList();
	}

	/**
	 * 清除按钮监听调用方法
	 */
	private void btnClear_P_call() {
		LinkList linkList = (LinkList) comboBox.getSelectedItem();
		if (linkList == null) {
			return;
		}
		linkList.clear();
		showMessage("Cleared!");
		showLinkList();
	}

	/**
	 * 获得链表元素个数按钮监听调用方法
	 */
	private void btnLength_P_call() {
		LinkList linkList = (LinkList) comboBox.getSelectedItem();
		if (linkList == null) {
			return;
		}
		int length = linkList.length();
		String className = linkList.getClass().getName();
		showMessage("Length of this " + className + " is " + length + " .");
	}

	/**
	 * 判断链表是否为空按钮监听调用方法
	 */
	private void btnIsEmpty_P_call() {
		LinkList linkList = (LinkList) comboBox.getSelectedItem();
		if (linkList == null) {
			return;
		}
		String className = linkList.getClass().getName();
		if (linkList.isEmpty()) {
			showMessage("This " + className + " is empty.");
		} else {
			showMessage("This " + className + " is not empty.");
		}
	}

	/**
	 * 获得链表元素值的按钮监听调用
	 */
	private void btnGet_P_call() {
		// 判断是否输入了索引
		if (textIndex_Get.getText().length() < 1) {
			textValue_Get.setText("input an index!");
			return;
		}
		LinkList linkList = (LinkList) comboBox.getSelectedItem();
		Object data;
		try {
			int index = Integer.parseInt(textIndex_Get.getText());
			data = linkList.getNodeData(index);
		} catch (Exception e) {
			textValue_Get.setText(e.getMessage());
			textIndex_Get.setText("");
			return;
		}
		if ("LinkList".equals(linkList.getClass().getName())) {// 选择的是链表
			String value = (String) data;
			textValue_Get.setText(value);
		} else {// 选中的是多项式
			Term value = (Term) data;
			textValue_Get.setText(value.toString());
		}
	}

	/**
	 * 插入元素按钮监听调用方法
	 */
	private void btnInsert_P_call() {
		if (textIndex_Insert.getText().length() < 1) {// 是否输入了插入元素的索引
			labelResult_Insert.setText("input the index.");
			return;
		}
		if (textValue_Insert.getText().length() < 1) {// 是否输入的插入元素的值
			labelResult_Insert.setText("input the value.");
			return;
		}
		LinkList linkList = (LinkList) comboBox.getSelectedItem();
		if ("LinkList".equals(linkList.getClass().getName())) {// 选中的是链表
			try {
				int index = Integer.parseInt(textIndex_Insert.getText());
				linkList.addNode(textValue_Insert.getText(), index);
			} catch (Exception e) {
				labelResult_Insert.setText(e.getMessage());
				textIndex_Insert.setText("");
				textValue_Insert.setText("");
				return;
			}
		} else {// 选中的是多项式
			try {
				int index = Integer.parseInt(textIndex_Insert.getText());
				String[] termStr = textValue_Insert.getText().split(":");
				int expn = Integer.parseInt(termStr[1]);
				double coef = Double.parseDouble(termStr[0]);
				Term term = new Term(coef, expn);
				Polynomial polynomial = (Polynomial) linkList;
				polynomial.addNode(term, index);
				polynomial.mergeSimilarTerms();
				polynomial.removeEmptyTerm();
			} catch (ArrayIndexOutOfBoundsException e) {
				labelResult_Insert.setText("Error Input!");
				return;
			} catch (Exception e) {
				labelResult_Insert.setText(e.getMessage());
				textIndex_Insert.setText("");
				textValue_Insert.setText("");
				return;
			}
		}
		labelResult_Insert.setText("Inserted!");
		textIndex_Insert.setText("");
		textValue_Insert.setText("");
		showLinkList();
	}

	/**
	 * 删除元素按钮监听调用
	 */
	private void btnDelect_P_call() {
		// 判断是否输入了索引
		if (textIndex_Delect.getText().length() < 1) {
			labelResult_Delect.setText("input the index.");
			return;
		}
		LinkList linkList = (LinkList) comboBox.getSelectedItem();
		try {
			int index = Integer.parseInt(textIndex_Delect.getText());
			linkList.removeNode(index);
		} catch (Exception e) {
			labelResult_Delect.setText(e.getMessage());
			textIndex_Delect.setText("");
			return;
		}
		textIndex_Delect.setText("");
		labelResult_Delect.setText("Delected!");
		showLinkList();
	}

	/**
	 * 查找元素按钮监听调用方法
	 */
	private void btnFind_P_call() {
		// 判断是否输入了数据
		if (textValue_Find.getText().length() < 1) {
			labelResult_find.setText("input the index.");
			return;
		}
		LinkList linkList = (LinkList) comboBox.getSelectedItem();
		if ("LinkList".equals(linkList.getClass().getName())) {// 选中的是链表
			try {
				String value = textValue_Find.getText();
				int index = linkList.indexOf(value);
				if (index >= 0) {// 找到了该节点
					labelResult_find.setText("value = " + value + " ; index = " + index);
				} else {// 未找到该节点
					labelResult_find.setText("Can't find " + value + " !");
				}
			} catch (Exception e) {
				labelResult_find.setText(e.getMessage());
				textValue_Find.setText("");
				return;
			}
		} else {// 选中的是多项式
			try {
				String[] termStr = textValue_Find.getText().split(":");
				int expn = Integer.parseInt(termStr[1]);
				double coef = Double.parseDouble(termStr[0]);
				Term term = new Term(coef, expn);
				int index = linkList.indexOf(term);
				if (index >= 0) {// 找到了该项
					labelResult_find.setText("value = " + term.toString() + " ; index = " + index);
				} else {// 无法找到该项
					labelResult_find.setText("Can't find " + term.toString() + " !");
				}
			} catch (ArrayIndexOutOfBoundsException e) {
				labelResult_find.setText("Error Input!");
				return;
			} catch (Exception e) {
				labelResult_Insert.setText(e.getMessage());
				textValue_Find.setText("");
				return;
			}
		}
		textValue_Find.setText("");
	}

	/**
	 * 切换到多项式加法页面按钮监听调用方法
	 */
	private void btnAdd_call() {
		// 是否创建了链表
		if (comboBox.getItemCount() == 0) {
			return;
		}
		// 当前选中的是否是多项式，只有多项式可以进行加法运算
		if (!"Polynomial".equals(comboBox.getSelectedItem().getClass().getName())) {
			showMessage("Please choose a Polynomial!");
			return;
		}
		// 移除加法运算页面中下拉框中的所有多项式
		comboBox_P.removeAllItems();
		// 将所有的多项式添加到加法运算页面的下拉选框中
		for (int i = 0; i < comboBox.getItemCount(); i++) {
			String className = comboBox.getItemAt(i).getClass().getName();
			if ("Polynomial".equals(className)) {
				comboBox_P.addItem(comboBox.getItemAt(i));
			}
		}
		// 移除当前选中的多项式
		comboBox_P.removeItem(comboBox.getSelectedItem());
		// 如果加法运算页面中的下拉框没有多项式（只创建了一个多项式），无法进行加法运算
		if (comboBox_P.getItemCount() < 1) {
			showMessage("There was not enough Polynomial!");
			return;
		}
		// 跳转到加法运算页面
		switchPanel("Add");
	}

	/**
	 * 加法运算按钮监听调用方法
	 */
	private void btnAdd_P_call() {
		Polynomial polynomialAdd = (Polynomial) comboBox_P.getSelectedItem();
		Polynomial polynomial = (Polynomial) comboBox.getSelectedItem();
		polynomial.addPolynomial(polynomialAdd);
		showLinkList();
		showMessage("Added a Polynomial!");
	}
}
